﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace GameLib1
{
    class Circle
    {
        const float PRECISION = 0.01f;
        public Vector2 mPos;
        public float mRadius;

        public Circle()
        {
            mPos = new Vector2();
            mRadius = 0;
        }

        public Circle(Vector2 pos, float radius)
        {
            mPos = pos;
            mRadius = radius;
        }

        public Circle(Circle copy)
        {
            mPos = new Vector2(copy.mPos.X, copy.mPos.Y);
            mRadius = copy.mRadius;
        }

        public bool CollidesWith(Circle rhs)
        {
            if ((rhs.mRadius + mRadius) * (rhs.mRadius + mRadius) < (Vector2.DistanceSquared(mPos, rhs.mPos)))
                return true;
            return false;
        }

        public bool DeltaCollidesWith( Vector2 vel, Circle rhs, Vector2 rhs_vel)
        {
            Circle temp_this = new Circle(this) ;
            Circle temp_that = new Circle(rhs);

            for (float t = 0; t < 1.0f; t += PRECISION)
            {
                temp_this.mPos = mPos     +     vel * t;
                temp_that.mPos = rhs.mPos + rhs_vel * t;

                if (temp_this.CollidesWith(temp_that))
                    return true;
            }

            return false;
        }

        public static Circle GetMouse()
        {
            return new Circle(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), 32);
        }

    }
}
